<template>
  <div class="text_box">
    <h2>{{ text.title }}</h2>
    <div class="metadata">
      <span class="author-id"><strong>作者:</strong> {{ text.username}}</span>
      <span class="date"><strong>日期:</strong> {{ text.date }}</span>
      <span class="type"><strong>类型:</strong> {{ text.kind }}</span>
      <span class="read-count"><strong>阅读量:</strong> {{ text.read }}</span>
      <span class="favorite-count"><strong>收藏数:</strong> {{ text.collect }}</span>
      <span class="like-count"><strong>点赞数:</strong> {{ text.like }}</span>
    </div>
    <div v-html="text.text" class="content"></div>
  </div>
</template>

<script setup>
import { defineProps, onMounted } from 'vue';

const props = defineProps({
  text: {
    type: Object,
    required: true
  }
});

onMounted(() => {
  console.log(props.text);
});
</script>

<style scoped>
.text_box {
  min-width: 100%;
  max-width: 800px;
  height: 100%;
  border-radius: 8px;
  padding: 20px;
}

.text_box > h2 {
  margin-top: 10px;
  height: auto;
  text-align: center;
  color: #2c3e50;
  padding-bottom: 10px;
}

.metadata {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  margin-bottom: 20px;
  padding: 10px;
  border-radius: 5px;
}

.metadata > span {
  margin: 5px 0;
  font-size: 14px;
  color: #4a5568; /* 改为中灰色文字 */
}

.metadata strong {
  color: #2c3e50; /* 强调文字改为深蓝色 */
}

.content {
  line-height: 1.6;
  height: auto;
  color: #4a5568; /* 正文文字颜色调整 */
  overflow: auto; /* 添加溢出处理 */
}

/* 为v-html内容添加基本颜色样式 */
.content :deep(a) {
  color: #3182ce; /* 链接颜色 */
}

.content :deep(a:hover) {
  color: #1a73e8; /* 链接悬停颜色 */
}
</style>